<template>
  <ul class="bw-com-node-info-list">
    <li class="bw-com-node-info-item">
      <span class="label"> 节点ID </span>
      <BwCopyInput :readonly="true" :value="curNodeId" />
    </li>

    <li class="bw-com-node-info-item">
      <span class="label"> 节点名称 </span>
      <a-input v-model:value="curNodeName" />
    </li>
  </ul>
</template>

<script lang="ts" setup>
import { computed } from 'vue'
import { useComDesignStoreWithOut } from '@/store'
import { BwCopyInput } from '@/components/copyInput'

const designStore = useComDesignStoreWithOut()
const curNodeId = computed(() => {
  const curNode = designStore.selectNodeEle
  return curNode?.nodeId ?? ''
})
const curNodeName = computed({
  get: () => {
    const curNode = designStore.selectNodeEle
    return curNode?.nodeName ?? ''
  },
  set: (value) => {
    const curNode = designStore.selectNodeEle
    if (curNode) {
      const nodeId = curNode.nodeId
      designStore.onChangeNodeName(nodeId, value)
    }
  },
})
</script>

<style lang="less" scoped>
.bw-com-node-info-list {
  padding: 0 16px;
  width: calc(100% - 32px);

  .bw-com-node-info-item {
    width: 100%;
    margin-bottom: 8px;

    .label {
      font-size: 12px;
      font-weight: 600;
      margin-bottom: 3px;
    }
  }
}
</style>
